import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { UserModule } from './user/user.module';
import { ConfigModule } from '@nestjs/config';
import envConfig from './config/envConfig';
import { DatabaseModule } from './flutter/database/database.module';
import { APP_GUARD } from '@nestjs/core';
import { JwtAuthGuard } from './global/guard/jwt-auth.guard';
import { JwtStrategy } from './global/strategy/jwt.strategy';
import { PassportModule } from '@nestjs/passport';

@Module({
  imports: [
    ConfigModule.forRoot({
      isGlobal: true,
      envFilePath: [envConfig.path],
    }),
    DatabaseModule, // 导入数据库模块,
    UserModule,
    // PassportModule.register({ defaultStrategy: 'jwt' }), // 确保注册默认策略
  ],
  controllers: [AppController],
  providers: [
    AppService,
    JwtStrategy,
    {
      provide: APP_GUARD,
      useClass: JwtAuthGuard,
    },
  ],
})
export class AppModule {}
